package com.SweetWhite.UserManagement.model.controller;

import java.io.File;
import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;


@Controller
public class UploadController{
	@Autowired
	private HttpServletRequest req;
@RequestMapping("upload")
public void upload(String filedesc,@RequestParam("fileup") MultipartFile fileup) throws IOException, ServletException{
	System.out.println(filedesc);
	String filepath=req.getSession().getServletContext().getRealPath("/fileUpload");
	System.out.println(filepath);
	fileup.transferTo(new File(filepath+"/temp/"+fileup.getOriginalFilename()));
		
		HttpSession session=req.getSession();
		session.setAttribute("message", "上传成功");
}
}
